package mvc.struts.annotation.util;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public final class StreamUtil {

	private static final Logger LOGGER = LoggerFactory.getLogger(StreamUtil.class);
	
	/**
	 * 
	 * @param is
	 * @return
	 */
	public static String getString(InputStream is)
	{
		StringBuilder	sb = new StringBuilder();
		
		try
		{
			BufferedReader	reader = new BufferedReader(new InputStreamReader(is));
			
			String 	line;
			
			while	((line = reader.readLine()) != null) {
				sb.append(line);
			}
		} 
		catch(Exception ex)
		{
			LOGGER.error("get string failure", ex);
			throw	new	RuntimeException(ex);
		}
		
		return	sb.toString();
	}
		
}
